package demo3;

import java.util.concurrent.CountDownLatch;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-08-11
 * Time: 17:29
 */
public class Testdemo2 {

    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(10);

        for(int i =0;i<10;++i){
            Thread t = new Thread(()->{
                try {
                    System.out.println("开始比赛");
                    Thread.sleep(3000);
                    countDownLatch.countDown();//某个子任务完成
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            });
            t.start();
        }
        countDownLatch.await();
        System.out.println("比赛完成");
    }



}
